function func(value, world, has) {
  // console.log(value);
  // console.log(world);
  // console.log(has);
}
const world = '世界！';
const text = func`你好！${ world }.`;

/**
 * 首先会传入一个函数
 *  
 */
const myCurry = (func) => {
  return function contentFun(...args) {
    if (func.length !== args.length) {
      return function() {
        return contentFun(...args.concat(Array.from(arguments)));
      }
    }
    return func.apply(func, args);
  }
};

// const myCurry = (func) => {
//   const arr = [];
//   return function contentFun() {
//     arr.push(...arguments);
//     return func.length !== arr.length ? contentFun : func.apply(func, arr);
//   }
// };

const a = function(a, b, c) {
  return a + b + c;
};

const curryFun = myCurry(a);
const b = curryFun(1)(2)(3);

// console.log(b, 'b');

Array.prototype.selfReduce = function(fn, resultType) {
  let defaultNum = 0;
  if (resultType === undefined) {
    resultType = this[0];
    defaultNum = 1;
  }
  for(let i = defaultNum; i < this.length; i++) {
    resultType = fn(resultType, this[i], i, this);
  }
  return resultType;
};

const arr1 = [1, 2, 3];
const arr2 = [{age: 1}, {age: 5}, {age: 3}];
const nums = arr2.selfReduce((a, b) => {
  return a += b.age;
}, 0);

console.log(nums);
